Refactor Int32 to use Int32Native pattern matching Int64 architecture#12828
Refactor Int32 to use Int32Native pattern matching Int64 architecture#12828Simn merged 5 commits intohaxe-numericfrom
Conversation
- Create std/haxe/numeric/Int32Native.hx as cross-platform abstract(Int) with masking - Create JVM, HL, C++, Neko target overrides in _std directories - Refactor std/haxe/Int32.hx to thin @:op layer delegating to Int32Native - Add comprehensive TestInt32 unit test class - All tests passing on interp, JS, JVM, Neko, Python, PHP Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
…docs and @:coreApi - Move #if !cpp to cover entire testArrayIndexWithInt32 function (avoids utest "no assertions") - Remove Neko-specific Int32Native override (cross-platform version works correctly via Float auto-promotion) - Remove doc comments from target-specific Int32Native files (docs belong on main Int32 type) - Remove unnecessary @:coreApi(check = Off) from private types (Implied check handles these) - Add platform representation docs to main Int32.hx Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
The only failing target is now C++ which we'll have to look into still. We first need to identify what actually changed because this was fine before. Along those lines, I've checked our GitHub issues list for int32 occurrences and paste the links here so we can check if all these cases are covered by the tests: |
|
@copilot Please continue! |
…ove @:coreApi from Int64Native, add issue regression tests Co-authored-by: Simn <634365+Simn@users.noreply.github.com>
Done in 6dd7641:
|
Reworks
haxe.Int32to follow the sameNativedelegation pattern established forInt64in #12826, verifying the system's flexibility for future numeric type unification.Architecture
haxe/Int32.hx→ thin@:opabstract overInt32Native, no platform logic. Documents platform representations (native 32-bit on C++/JVM/HL, clamped on JS/PHP/Python/Lua, Float auto-promoted on Neko).haxe/numeric/Int32Native.hx→ cross-platformabstract(Int)with masking (JS|0, PHP sign-extend, Python modular arithmetic, LuaclampInt32). Also used by Neko, where NekoVM auto-promotes values exceeding 31-bit range to Float while preserving correct 32-bit arithmetic.haxe/numeric/Int32Direct.hx→ shared no-masking implementation for targets whereIntis natively 32-bit. Uses~x+1for negation to avoid a CPPIA unary-minus overflow bug.{jvm,hl,cpp}/_std/haxe/numeric/Int32Native.hx→ single-line overrides:typedef Int32Native = Int32Direct.{jvm,hl,cpp}/_std/haxe/numeric/Int64Native.hx→ removed unnecessary@:coreApi(check = Off)(private types get theImpliedcheck which silently ignores failures).Tests
TestInt32class: overflow wrap, increment/decrement at boundaries, bitwise ops, shifts, unsigned comparison, mixed-type arithmetic,Floatconversion, regression coverage from Fix for #7485 - Int32 negate missing clamp #7491|=not clamping on Python ([python] "<Int32> |= <Int>" not clamping result to 32 bits #5938)Example
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.